package com.mapbar.ure.frontend.lr1.table;

import com.mapbar.ure.frontend.lr1.LR1Item;

public class ActionItem {
	public ActionItem(ActionType acc) {
		this.type = acc;
	}

	public ActionItem(ActionType type, int shiftValue) {
		this.type = type;
		this.shiftValue = shiftValue;
	}

	public ActionItem(ActionType type, LR1Item item) {
		this.type = type;
		this.item = item;
	}

	public ActionType type;
	public int shiftValue = 0;;
	public LR1Item item = null;

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		switch (type) {
		case Accept:
			sb.append(type);
			sb.append("\n");
			break;
		case Reduce:
			sb.append(type);
			sb.append(item.toString());
			sb.append("\n");
			break;
		case Shift:
			sb.append(type);
			sb.append(shiftValue);
			sb.append("\n");
			break;
		default:
			break;
		}

		return super.toString();
	}
}
